package com.lz.yz.outing.service;

import com.lz.yz.base.util.HttpClientUtils;
import com.lz.yz.outing.config.PushConfig;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 28458 on 2018/1/2.
 */
@Service
public class PushService {

    private final Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    PushConfig pushConfig;

    public void push(String alias, String msg) {
        JSONObject param = new JSONObject();
        param.put("method","publish_to_alias");
        param.put("appkey",pushConfig.getYbAppkey());
        param.put("seckey",pushConfig.getYbSecret());
        param.put("alias",alias);
        param.put("msg",msg);
        JSONObject result = HttpClientUtils.httpPost("http://rest.yunba.io:8080",param);
        logger.info(result.toString());
    }


}
